package com.yuyang.wifi.dialog;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.TextView;

import com.yuyang.wifi.R;
import com.yuyang.wifi.views.CircleProgress;

import androidx.annotation.Nullable;


public class AddMainScreenDialog extends CommonDialog {

    private TextView tvCancel, tvAdd, tvOneKey, tvNum;
    private View mIvClose;
    private Context mContext;

    private String mTitle, mContent, mConfirmText, mCancelText;
    private CircleProgress circleProgress;

    public static AddMainScreenDialog newInstance() {
        AddMainScreenDialog dialog = new AddMainScreenDialog();
        Bundle data = new Bundle();
        dialog.setArguments(data);
        return dialog;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public int getLayoutId() {
        return R.layout.dialog_add_main_screen_layout;
    }

    @Override
    public void viewCreated(View view, @Nullable Bundle savedInstanceState) {
        tvCancel = (TextView) view.findViewById(R.id.tv_cancel);
        tvAdd = (TextView) view.findViewById(R.id.tv_add);
        tvOneKey = (TextView) view.findViewById(R.id.tv_one_key);
        tvNum = (TextView) view.findViewById(R.id.tv_num);
        circleProgress = (CircleProgress) view.findViewById(R.id.circle_progress);

        //圆形进度条
        circleProgress.setAnimDuration(2000);
        circleProgress.setInterpolator(new AccelerateDecelerateInterpolator());
        circleProgress.setSweepValue(30);
        circleProgress.anim();

        tvNum.setText("60%");

//        Integer total = Integer.valueOf(activityPrice);
//        Integer part = Integer.valueOf(userActivityPrice);
//        memActivityMoney.setText(FormatMoneyUtil.pennyChangeDollar(Long.valueOf(userActivityPrice)) + "元");
//        if (part <= total) {
//            NumberFormat numberFormat = NumberFormat.getInstance();
//            String result = numberFormat.format((float) part / (float) total * 100);
//            int abc = Double.valueOf(result).intValue();//转换为Int类型
//            // 设置精确到小数点后2位
//            //圆形进度条
//            circleProgress.setAnimDuration(2000);
//            circleProgress.setInterpolator(new AccelerateDecelerateInterpolator());
//            circleProgress.setSweepValue(abc);
//            circleProgress.anim();
//        } else {
//            circleProgress.setSweepValue(100);
//        }
        tvAdd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (mDialogListener != null) {
                    mDialogListener.onConfirm();
                }
            }
        });

        tvCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

        tvOneKey.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
                if (mDialogListener != null) {
                    mDialogListener.onSendCode();
                }
            }
        });
    }

    @Override
    public boolean isCancelable() {
        return true;
    }

    public void setData(Context context) {
        this.mContext = context;
    }

}
